#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
    client_requests_zeep.py
    ~~~~~~~~~~~~~~~~~~~~~~~

    模拟客户端请求——zeep版本

    :author: nut
    :copyright: (c) 2020, Comcat
    :date created: 2020-12-02
    :python version: 3.5
"""
from zeep import Client

ip = '127.0.0.1'
port = 8901
client = Client("http://%s:%s/?wsdl" % (ip, port))
# print(client.wsdl.dump()) # 解析wsdl
# print('=' * 20)

### say_hello
r = client.service.say_hello('zhansgan', 3)
print(r)
print('-' * 20)

### say_hello_1
factory = client.type_factory("ns0")
person = factory.Person(name='zhangsan', age=23)
persons = factory.PersonArray([person, person])
r = client.service.say_hello_1(persons)
print(r)
print('-' * 20)

### say_hello_2
factory = client.type_factory("ns0")
persons = factory.stringArray(["zhansgan", "lisi"])
r = client.service.say_hello_2(persons)
print(r)
print('-' * 20)

### say_hello_3
# factory = client.type_factory("ns0")
person = {"name": u"张三", "age": 23}
r = client.service.say_hello_3(person)
print(r)